home *** CD-ROM | disk | FTP | other *** search
Wrap
G++(1) GNU Tools G++(1) NNNNAAAAMMMMEEEE g++ - GNU project C++ Compiler (v2.4) SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS g++ [[[[_o_p_t_i_o_n | _f_i_l_e_n_a_m_e ]... DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN The C and C++ compilers are integrated; gggg++++++++ is a script to call ggggcccccccc wwwwiiiitttthhhh ooooppppttttiiiioooonnnnssss ttttoooo rrrreeeeccccooooggggnnnniiiizzzzeeee CCCC++++++++.... ggggcccccccc processes input files through one or more of four stages: preprocessing, compilation, assembly, and linking. This man page contains full descriptions for _o_n_l_y C++ specific aspects of the com- piler, though it also contains summaries of some general- purpose options. For a fuller explanation of the compiler, see ggggcccccccc(1111). C++ source files use one of the suffixes `....CCCC', `....cccccccc', or `....ccccxxxxxxxx'; preprocessed C++ files use the suffix `....iiiiiiii'. OOOOPPPPTTTTIIIIOOOONNNNSSSS There are many command-line options, including options to control details of optimization, warnings, and code genera- tion, which are common to both ggggcccccccc and gggg++++++++. For full infor- mation on all options, see ggggcccccccc(1111). Options must be separate: `----ddddrrrr' is quite different from `---- dddd ----rrrr '. Most `----ffff' and `----WWWW' options have two contrary forms: ---- ffff_n_a_m_e and ---- ffffnnnnoooo ---- _n_a_m_e (or ----WWWW_n_a_m_e and ----WWWWnnnnoooo----_n_a_m_e). Only the non- default forms are shown here. ----cccc Compile or assemble the source files, but do not link. The compiler output is an object file corresponding to each source file. ----DDDD_m_a_c_r_o Define macro _m_a_c_r_o with the string `1111' as its defini- tion. ----DDDD_m_a_c_r_o====_d_e_f_n Define macro _m_a_c_r_o as _d_e_f_n. ----EEEE Stop after the preprocessing stage; do not run the compiler proper. The output is preprocessed source code, which is sent to the standard output. ----ffffaaaallllllll----vvvviiiirrrrttttuuuuaaaallll Treat all possible member functions as virtual, impli- citly. All member functions (except for constructor functions and nnnneeeewwww or ddddeeeelllleeeetttteeee member operators) are GNU Tools Last change: 30apr1993 1 G++(1) GNU Tools G++(1) treated as virtual functions of the class where they appear. This does not mean that all calls to these member func- tions will be made through the internal table of vir- tual functions. Under some circumstances, the compiler can determine that a call to a given virtual function can be made directly; in these cases the calls are direct in any case. ----ffffddddoooollllllllaaaarrrrssss----iiiinnnn----iiiiddddeeeennnnttttiiiiffffiiiieeeerrrrssss Permit the use of `$$$$' in identifiers. Traditional C allowed the character `$$$$' to form part of identifiers; by default, GNU C also allows this. However, ANSI C forbids `$$$$' in identifiers, and GNU C++ also forbids it by default on most platforms (though on some platforms it's enabled by default for GNU C++ as well). ----ffffeeeelllliiiiddddeeee----ccccoooonnnnssssttttrrrruuuuccccttttoooorrrrssss Use this option to instruct the compiler to be smarter about when it can elide constructors. Without this flag, GNU C++ and cfront both generate effectively the same code for: A foo (); A x (foo ()); // x initialized by `foo ()', no ctor called A y = foo (); // call to `foo ()' heads to temporary, // y is initialized from the temporary. Note the difference! With this flag, GNU C++ initial- izes `yyyy' directly from the call to ffffoooooooo (((()))) without going through a temporary. ----ffffeeeennnnuuuummmm----iiiinnnntttt----eeeeqqqquuuuiiiivvvv Normally GNU C++ allows conversion of eeeennnnuuuummmm to iiiinnnntttt, but not the other way around. Use this option if you want GNU C++ to allow conversion of iiiinnnntttt to eeeennnnuuuummmm as well. ----ffffeeeexxxxtttteeeerrrrnnnnaaaallll----tttteeeemmmmppppllllaaaatttteeeessss Produce smaller code for template declarations, by gen- erating only a single copy of each template function where it is defined. To use this option successfully, you must also mark all files that use templates with either `####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn' (the definition) or `####pppprrrraaaaggggmmmmaaaa iiiinnnntttteeeerrrrffffaaaacccceeee' (declarations). When your code is compiled with `----ffffeeeexxxxtttteeeerrrrnnnnaaaallll----tttteeeemmmmppppllllaaaatttteeeessss', all template instantiations are external. You must arrange for all necessary instantiations to appear in the implementation file; you can do this with a ttttyyyyppppeeeeddddeeeeffff that references each instantiation needed. Conversely, when you compile using the default option `----ffffnnnnoooo---- GNU Tools Last change: 30apr1993 2 G++(1) GNU Tools G++(1) eeeexxxxtttteeeerrrrnnnnaaaallll----tttteeeemmmmppppllllaaaatttteeeessss', all template instantiations are explicitly internal. ----ffffnnnnoooo----ggggnnnnuuuu----lllliiiinnnnkkkkeeeerrrr Do not output global initializations (such as C++ con- structors and destructors) in the form used by the GNU linker (on systems where the GNU linker is the standard method of handling them). Use this option when you want to use a non-GNU linker, which also requires using the ccccoooolllllllleeeecccctttt2222 program to make sure the system linker includes constructors and destructors. (ccccoooolllllllleeeecccctttt2222 is included in the GNU CC distribution.) For systems which _m_u_s_t use ccccoooolllllllleeeecccctttt2222, the compiler driver ggggcccccccc is configured to do this automatically. ----ffffmmmmeeeemmmmooooiiiizzzzeeee----llllooooooookkkkuuuuppppssss ----ffffssssaaaavvvveeee----mmmmeeeemmmmooooiiiizzzzeeeedddd These flags are used to get the compiler to compile programs faster using heuristics. They are not on by default since they are only effective about half the time. The other half of the time programs compile more slowly (and take more memory). The first time the compiler must build a call to a member function (or reference to a data member), it must (1) determine whether the class implements member functions of that name; (2) resolve which member func- tion to call (which involves figuring out what sorts of type conversions need to be made); and (3) check the visibility of the member function to the caller. All of this adds up to slower compilation. Normally, the second time a call is made to that member function (or reference to that data member), it must go through the same lengthy process again. This means that code like this cout << "This " << p << " has " << n << " legs.\n"; makes six passes through all three steps. By using a software cache, a ``hit'' significantly reduces this cost. Unfortunately, using the cache introduces another layer of mechanisms which must be implemented, and so incurs its own overhead. `---- ffffmmmmeeeemmmmooooiiiizzzzeeee ---- llllooooooookkkkuuuuppppssss' enables the software cache. Because access privileges (visibility) to members and member functions may differ from one function context to the next, gggg++++++++ may need to flush the cache. With the ` ---- ffffmmmmeeeemmmmooooiiiizzzzeeee ----llllooooooookkkkuuuuppppssss' flag, the cache is flushed after every function that is compiled. The `-fsave-memoized' flag enables the same software cache, but when the GNU Tools Last change: 30apr1993 3 G++(1) GNU Tools G++(1) compiler determines that the context of the last func- tion compiled would yield the same access privileges of the next function to compile, it preserves the cache. This is most helpful when defining many member func- tions for the same class: with the exception of member functions which are friends of other classes, each member function has exactly the same access privileges as every other, and the cache need not be flushed. ----ffffnnnnoooo----ddddeeeeffffaaaauuuulllltttt----iiiinnnnlllliiiinnnneeee Do not make member functions inline by default merely because they are defined inside the class scope. Oth- erwise, when you specify ----OOOO, member functions defined inside class scope are compiled inline by default; i.e., you don't need to add `iiiinnnnlllliiiinnnneeee' in front of the member function name. ----ffffnnnnoooo----ssssttttrrrriiiicccctttt----pppprrrroooottttoooottttyyyyppppeeee Consider the declaration iiiinnnntttt ffffoooooooo (((())));;;;. In C++, this means that the function ffffoooooooo takes no arguments. In ANSI C, this is declared iiiinnnntttt ffffoooooooo((((vvvvooooiiiidddd))));;;;. With the flag ` ---- ffffnnnnoooo ----ssssttttrrrriiiicccctttt----pppprrrroooottttoooottttyyyyppppeeee', declaring functions with no arguments is equivalent to declaring its argument list to be untyped, i.e., iiiinnnntttt ffffoooooooo (((())));;;; is equivalent to say- ing iiiinnnntttt ffffoooooooo ((((............))));;;;. ----ffffnnnnoooonnnnnnnnuuuullllllll----oooobbbbjjjjeeeeccccttttssss Normally, GNU C++ makes conservative assumptions about objects reached through references. For example, the compiler must check that `aaaa' is not null in code like the following: obj &a = g (); a.f (2); Checking that references of this sort have non-null values requires extra code, however, and it is unneces- sary for many programs. You can use ` ---- ffffnnnnoooonnnnnnnnuuuullllllll ---- oooobbbbjjjjeeeeccccttttssss' to omit the checks for null, if your program doesn't require the default checking. ----ffffhhhhaaaannnnddddlllleeee----ssssiiiiggggnnnnaaaattttuuuurrrreeeessss ----ffffnnnnoooo----hhhhaaaannnnddddlllleeee----ssssiiiiggggnnnnaaaattttuuuurrrreeeessss These options control the recognition of the ssssiiiiggggnnnnaaaattttuuuurrrreeee and ssssiiiiggggooooffff constructs for specifying abstract types. By default, these constructs are not recognized. ----fffftttthhhhiiiissss----iiiissss----vvvvaaaarrrriiiiaaaabbbblllleeee The incorporation of user-defined free store management into C++ has made assignment to tttthhhhiiiissss an anachronism. Therefore, by default GNU C++ treats the type of tttthhhhiiiissss in a member function of ccccllllaaaassssssss XXXX to be XXXX ****ccccoooonnnnsssstttt. In other words, it is illegal to assign to tttthhhhiiiissss within a GNU Tools Last change: 30apr1993 4 G++(1) GNU Tools G++(1) class member function. However, for backwards compati- bility, you can invoke the old behavior by using ` ---- fffftttthhhhiiiissss----iiiissss----vvvvaaaarrrriiiiaaaabbbblllleeee'. ---- gggg Produce debugging information in the operating system's native format (for DBX or SDB or DWARF). GDB also can work with this debugging information. On most systems that use DBX format, `----gggg' enables use of extra debugging information that only GDB can use. Unlike most other C compilers, GNU CC allows you to use ` ----gggg' with `----OOOO'. The shortcuts taken by optimized code may occasionally produce surprising results: some vari- ables you declared may not exist at all; flow of con- trol may briefly move where you did not expect it; some statements may not be executed because they compute constant results or their values were already at hand; some statements may execute in different places because they were moved out of loops. Nevertheless it proves possible to debug optimized out- put. This makes it reasonable to use the optimizer for programs that might have bugs. ----IIII_d_i_r Append directory _d_i_r to the list of directories searched for include files. ----LLLL_d_i_r Add directory _d_i_r to the list of directories to be searched for `----llll'. ----llll_l_i_b_r_a_r_y Use the library named _l_i_b_r_a_r_y when linking. (C++ pro- grams often require `-lg++' for successful linking.) ----nnnnoooossssttttddddiiiinnnncccc Do not search the standard system directories for header files. Only the directories you have specified with ---- IIII options (and the current directory, if appropriate) are searched. ----nnnnoooossssttttddddiiiinnnncccc++++++++ Do not search for header files in the standard direc- tories specific to C++, but do still search the other standard directories. (This option is used when build- ing libg++.) ----OOOO Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function. ----oooo _f_i_l_e GNU Tools Last change: 30apr1993 5 G++(1) GNU Tools G++(1) Place output in file _f_i_l_e. ----SSSS Stop after the stage of compilation proper; do not assemble. The output is an assembler code file for each non-assembler input file specified. ----ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll Attempt to support some aspects of traditional C com- pilers. Specifically, for both C and C++ programs: +o In the preprocessor, comments convert to nothing at all, rather than to a space. This allows traditional token concatenation. +o In the preprocessor, macro arguments are recognized within string constants in a macro definition (and their values are stringified, though without additional quote marks, when they appear in such a context). The preprocessor always considers a string constant to end at a newline. +o The preprocessor does not predefine the macro ________SSSSTTTTDDDDCCCC________ when you use ` ---- ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll', but still predefines________GGGGNNNNUUUUCCCC________ (since the GNU extensions indicated by ________GGGGNNNNUUUUCCCC________ are not affected by `----ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll'). If you need to write header files that work differently depending on whether `----ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll' is in use, by test- ing both of these predefined macros you can distinguish four situations: GNU C, traditional GNU C, other ANSI C compilers, and other old C compilers. +o In the preprocessor, comments convert to nothing at all, rather than to a space. This allows traditional token concatenation. +o In the preprocessor, macro arguments are recognized within string constants in a macro definition (and their values are stringified, though without additional quote marks, when they appear in such a context). The preprocessor always considers a string constant to end at a newline. +o The preprocessor does not predefine the macro ________SSSSTTTTDDDDCCCC________ when you use ` ---- ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll', but still predefines________GGGGNNNNUUUUCCCC________ (since the GNU extensions indicated by ________GGGGNNNNUUUUCCCC________ are not affected by `----ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll'). If you need to write header files that work differently depending on whether `----ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll' is in use, by test- ing both of these predefined macros you can distinguish four situations: GNU C, traditional GNU C, other ANSI C GNU Tools Last change: 30apr1993 6 G++(1) GNU Tools G++(1) compilers, and other old C compilers. +o String ``constants'' are not necessarily constant; they are stored in writable space, and identical look- ing constants are allocated separately. For C++ programs only (not C), `----ttttrrrraaaaddddiiiittttiiiioooonnnnaaaallll' has one additional effect: assignment to tttthhhhiiiissss is permitted. This is the same as the effect of `----fffftttthhhhiiiissss----iiiissss----vvvvaaaarrrriiiiaaaabbbblllleeee'. ----UUUU_m_a_c_r_o Undefine macro _m_a_c_r_o. ----WWWWaaaallllllll Issue warnings for conditions which pertain to usage that we recommend avoiding and that we believe is easy to avoid, even in conjunction with macros. ----WWWWeeeennnnuuuummmm----ccccllllaaaasssshhhh Warn when converting between different enumeration types. ----WWWWoooovvvveeeerrrrllllooooaaaaddddeeeedddd----vvvviiiirrrrttttuuuuaaaallll In a derived class, the definitions of virtual func- tions must match the type signature of a virtual func- tion declared in the base class. Use this option to request warnings when a derived class declares a func- tion that may be an erroneous attempt to define a vir- tual function: that is, warn when a function with the same name as a virtual function in the base class, but with a type signature that doesn't match any virtual functions from the base class. ----WWWWtttteeeemmmmppppllllaaaatttteeee----ddddeeeebbbbuuuuggggggggiiiinnnngggg When using templates in a C++ program, warn if debug- ging is not yet fully available. ----wwww Inhibit all warning messages. ++++eeee_N Control how virtual function definitions are used, in a fashion compatible with ccccffffrrrroooonnnntttt 1.x. PPPPRRRRAAAAGGGGMMMMAAAASSSS Two `####pppprrrraaaaggggmmmmaaaa' directives are supported for GNU C++, to per- mit using the same header file for two purposes: as a defin- ition of interfaces to a given object class, and as the full definition of the contents of that object class. ####pppprrrraaaaggggmmmmaaaa iiiinnnntttteeeerrrrffffaaaacccceeee Use this directive in header files that define object classes, to save space in most of the object files that use those classes. Normally, local copies of certain GNU Tools Last change: 30apr1993 7 G++(1) GNU Tools G++(1) information (backup copies of inline member functions, debugging information, and the internal tables that implement virtual functions) must be kept in each object file that includes class definitions. You can use this pragma to avoid such duplication. When a header file containing `####pppprrrraaaaggggmmmmaaaa iiiinnnntttteeeerrrrffffaaaacccceeee' is included in a compilation, this auxiliary information will not be generated (unless the main input source file itself uses `####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn'). Instead, the object files will contain references to be resolved at link time. ####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn ####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn """"_o_b_j_e_c_t_s....hhhh"""" Use this pragma in a main input file, when you want full output from included header files to be generated (and made globally visible). The included header file, in turn, should use `####pppprrrraaaaggggmmmmaaaa iiiinnnntttteeeerrrrffffaaaacccceeee'. Backup copies of inline member functions, debugging information, and the internal tables used to implement virtual functions are all generated in implementation files. If you use `####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn' with no argument, it applies to an include file with the same basename as your source file; for example, in `aaaallllllllccccllllaaaassssssss....cccccccc', `####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn' by itself is equivalent to `####pppprrrraaaaggggmmmmaaaa iiiimmmmpppplllleeeemmmmeeeennnnttttaaaattttiiiioooonnnn """"aaaallllllllccccllllaaaassssssss....hhhh""""'. Use the string argument if you want a single implementation file to include code from multiple header files. There is no way to split up the contents of a single header file into multiple implementation files. FFFFIIIILLLLEEEESSSS file.h C header (preprocessor) file file.i preprocessed C source file file.C C++ source file file.cc C++ source file file.cxx C++ source file file.s assembly language file file.o object file a.out link edited output _T_M_P_D_I_R/cc* temporary files _L_I_B_D_I_R/cpp preprocessor _L_I_B_D_I_R/cc1plus compiler _L_I_B_D_I_R/collect linker front end needed on some machines _L_I_B_D_I_R/libgcc.a GCC subroutine library /lib/crt[01n].o start-up routine _L_I_B_D_I_R/ccrt0 additional start-up routine for C++ /lib/libc.a standard C library, see _i_n_t_r_o(3) /usr/include standard directory for ####iiiinnnncccclllluuuuddddeeee files GNU Tools Last change: 30apr1993 8 G++(1) GNU Tools G++(1) _L_I_B_D_I_R/include standard gcc directory for ####iiiinnnncccclllluuuuddddeeee files _L_I_B_D_I_R/g++-include additional g++ directory for ####iiiinnnncccclllluuuuddddeeee _L_I_B_D_I_R is usually ////uuuussssrrrr////llllooooccccaaaallll////lllliiiibbbb////_m_a_c_h_i_n_e/_v_e_r_s_i_o_n. _T_M_P_D_I_R comes from the environment variable TTTTMMMMPPPPDDDDIIIIRRRR (default ////uuuussssrrrr////ttttmmmmpppp if available, else ////ttttmmmmpppp). SSSSEEEEEEEE AAAALLLLSSSSOOOO gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1). `ggggcccccccc', `ccccpppppppp', `aaaassss',````ld'''',,,, and `ggggddddbbbb' entries in iiiinnnnffffoooo. _U_s_i_n_g _a_n_d _P_o_r_t_i_n_g _G_N_U _C_C (_f_o_r _v_e_r_s_i_o_n _2._0), Richard M. Stallman; _T_h_e _C _P_r_e_p_r_o_c_e_s_s_o_r, Richard M. Stallman; _D_e_b_u_g_g_i_n_g _w_i_t_h _G_D_B: _t_h_e _G_N_U _S_o_u_r_c_e-_L_e_v_e_l _D_e_b_u_g_g_e_r, Richard M. Stallman and Roland H. Pesch; _U_s_i_n_g _a_s: _t_h_e _G_N_U _A_s_s_e_m_b_l_e_r, Dean Els- ner, Jay Fenlason & friends; _g_l_d: _t_h_e _G_N_U _l_i_n_k_e_r, Steve Chamberlain and Roland Pesch. BBBBUUUUGGGGSSSS For instructions on how to report bugs, see the GCC manual. CCCCOOOOPPPPYYYYIIIINNNNGGGG Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this per- mission notice are preserved on all copies. Permission is granted to copy and distribute modified ver- sions of this manual under the conditions for verbatim copy- ing, provided that the entire resulting derived work is dis- tributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above condi- tions for modified versions, except that this permission notice may be included in translations approved by the Free Software Foundation instead of in the original English. AAAAUUUUTTTTHHHHOOOORRRRSSSS See the GNU CC Manual for the contributors to GNU CC. GNU Tools Last change: 30apr1993 9